package com.sto.stoapp.activity.scanner.business;

import android.os.Bundle;
import android.view.View;

import com.sto.stoapp.activity.R;
import com.sto.stoapp.db.StoFilePreference;
import com.sto.stoapp.listener.StoOnClickListener;
import com.sto.stoapp.widget.StoHhmRadioButton;
import com.sto.stoapp.widget.StoHhmRadioButton.KeyUpListener;
import com.sto.stoapp.widget.StoHomeActivity;

public class StoTouchScreenLockSetActivity extends StoHomeActivity{
	
	private StoHhmRadioButton lock_open, lock_close;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sto_touch_screen_lock);
		Bundle extras = getIntent().getExtras();
		this.setTitleBottom(R.string.touch_screen_set,
				extras.getString("busiType"));
		initWidget();
		initListener();
	}
	
	private void initWidget(){
		lock_open = (StoHhmRadioButton) this.findViewById(R.id.touch_lock_open);
		lock_close = (StoHhmRadioButton) this.findViewById(R.id.touch_lock_close);
		
		if(StoFilePreference.getInstance(this).getlockTouchScreen()){
			lock_open.setChecked(true);
		}else{
			lock_close.setChecked(true);
		}
	}
	
	private void initListener(){
		lock_open.setKeyUpBack(new KeyUpListener() {
			
			@Override
			public void onKeyUpBack() {
				// TODO Auto-generated method sstub
				onBackPressed();
			}
		});
		
		lock_close.setKeyUpBack(new KeyUpListener() {
			
			@Override
			public void onKeyUpBack() {
				// TODO Auto-generated method stub
				onBackPressed();
			}
		});
		
		lock_open.setOnClickListener(new StoOnClickListener(this) {
			@Override
			public void mHonClick(View view) {
				lock_close.setChecked(false);
				StoFilePreference.getInstance(StoTouchScreenLockSetActivity.this).setlockTouchScreen(true);
			}
		});

		lock_close.setOnClickListener(new StoOnClickListener(this) {
			@Override
			public void mHonClick(View view) {
				lock_open.setChecked(false);
				StoFilePreference.getInstance(StoTouchScreenLockSetActivity.this).setlockTouchScreen(false);
			}
		});
	}
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}
}
